package com.groupwork.resourcemonitorcommon.common;


/**
 * 返回工具类
 *
 */
public class ResultUtils {

    /**
     * 成功带参数
     * @param data
     * @param <T>
     * @return
     */
    public static <T> BaseResponse<T> success(T data,String msg) {
        return new BaseResponse<>(0, data, msg);
    }

    /**
     *
     * 成功不带参数
     * @param msg
     * @return
     */
    public static <T> BaseResponse<T> success(String msg) {
        return new BaseResponse<>(0, null, msg);
    }

    /**
     * 失败不带消息
     *
     * @param errorCode
     * @return
     */
    public static BaseResponse error(ErrorCode errorCode) {
        return new BaseResponse<>(errorCode);
    }

    /**
     * 失败带消息
     *
     * @param errorCode
     * @return
     */
    public static BaseResponse error(int errorCode, String message) {
        return new BaseResponse(errorCode, null, message);
    }

    /**
     * 失败带消息
     *
     * @param errorCode
     * @return
     */
    public static BaseResponse error(ErrorCode errorCode, String message) {
        return new BaseResponse(errorCode.getCode(), null, message);
    }
}
